﻿// ----------------------------------------------------------------------
//
// <copyright file="IMVU_Helper.cs" company="TheAcidToy Inc" Date="2012">
//     TheAcidToy is a registered trademark of TheAcidToy Inc. All right reserved, copywrited: 2012
// </copyright>
//
// ------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.ComponentModel;

public class IMVU_Helper
{
    public static bool IsProcessOpen(string name)
    {
        foreach (Process clsProcess in Process.GetProcesses())
        {
            if (clsProcess.ProcessName.Contains(name))
            {
                return true;
            }
        }
        return false;
    }

    public static void kill_IMVU(string name)
    {
        foreach (Process p in System.Diagnostics.Process.GetProcessesByName(name))
        {
            try
            {
                p.Kill();
                p.WaitForExit(); // possibly with a timeout
            }
            catch (Win32Exception winException)
            {
                // process was terminating or can't be terminated - deal with it
            }
            catch (InvalidOperationException invalidException)
            {
                // process has already exited - might be able to let this one go
            }
        }
    }
}
